const alertComponent = {
data(){
return {
msg="警告框提示",
count:0
}
},
methods:{
click(){
alert(this.msg + this.count++)
}
},
props:["title"],
template:'<div><button @click="click">{{title}}</button></div>'
}
<my-alert title="按鈕1"></my-alert>
<my-alert title="按鈕2"></my-alert>